
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    if(navigator.geolocation) {
      // 地理位置服务可用
      navigator.geolocation.getCurrentPosition(function(position) {
        console.log(position);
      }, function(error) {
        console.log(error);
      });
    }
    else {
      // 地理位置服务不可用
    }
  </script>
</body>
</html>